const fs = require("fs");
const os = require("os");

// console.log(os.cpus());

const path = require("path");
console.log(path.basename("/a/b/c/d/e.html",".html"));
console.log(path.basename("/a/b/c/d"));
console.log(path.basename("./"));
console.log(path.dirname("/a/b/c/d/e.html"));
console.log(path.extname("/a/b/c/d/e.html"));


console.log(path.join("/a","/b","../c","d",".."));

// fs.writeFile("1.txt","Hello你好",function(err){
//     if(err) console.log(err);;
//     console.log("内容已保存");
// });
// fs.writeFileSync("2.txt","这是怎么了？");

// fs.readFile("1.txt",function(err,data){
//     if(err) throw err;
//     console.log('data',data.toString());
// });

let data = fs.readFileSync("2.txt");
console.log(data.toString());
console.log("继续");

// fs.copyFile("D:\\Pictures\\zm.jpg","zm.jpg",function(err){
//     if(err) throw err;
//     console.log("拷贝成功");
// });

// fs.mkdir("d:\\a\\b",{recursive:true},function(err){
//     if(err) throw err;
//     console.log("创建目录成功");
// });

// fs.rm("d:\\abc.ipynb",{recursive:false},function(err){
//     if(err) throw err;
//     console.log("删除目录成功");
// });

let url = new URL("https://user:pass@sub.example.com:8080/p/a/t/h?query=string#hash");
console.log(url.hostname);
console.log(url.protocol);
console.log(url.username);
console.log(url.password);
console.log(url.port);
console.log(url.pathname);
console.log(url.search);
console.log(url.searchParams);
console.log(url.hash);

console.log(url.searchParams.toString());
console.log(new URLSearchParams("a=1&b=2&c=3"));
console.log(new URLSearchParams({a:1,b:{bb:1,bbb:2},c:[1,2,3]}).toString());